import { http } from '@/utils/http'
import { components, paths } from '@/types/ApiInterface'

type GateCardListParams = {
  pageSize: number
  page: number
  cardId?: string
  createdAt?: string[]
  updatedAt?: string[]
  status?: boolean
  communityId?: string
}

type GateCardCreateParams = components['schemas']['GateCardCreateDto']
type GateCardUpdateParams = components['schemas']['GateCardUpdateDto']
type GateCardDeleteParams = components['schemas']['GateCardIdExistDto']

type CommunityUserStatusListParams =
  paths['/api/communityUserStatus/list']['get']['parameters']['query']

type CommunityUserStatusDetailParams =
  paths['/api/communityUserStatus/detail']['get']['parameters']['query']

/**
 * 获取门禁卡列表
 */
export const getGateCardListAPI = (params: GateCardListParams) => {
  return http.get<{
    list: components['schemas']['GateCardListResponse'][]
    total: number
    page: number
    pageSize: number
  }>('/api/gateCard/list', params)
}

/**
 * 创建门禁卡
 */
export const createGateCardAPI = (params: GateCardCreateParams) => {
  return http.post<components['schemas']['GateCardCreateResponse']>('/api/gateCard/create', params)
}

/**
 * 更新门禁卡
 */
export const updateGateCardAPI = (params: GateCardUpdateParams) => {
  return http.post<components['schemas']['GateCardUpdateResponse']>('/api/gateCard/update', params)
}

/**
 * 删除门禁卡
 */
export const deleteGateCardAPI = (params: GateCardDeleteParams) => {
  return http.post<string>('/api/gateCard/delete', params)
}

/**
 * 获取社区用户状态列表
 */
export const communityUserStatusListAPI = (params: CommunityUserStatusListParams) => {
  return http.get<{
    list: components['schemas']['CommunityUserStatus'][]
    total: number
    page: number
    pageSize: number
  }>('/api/communityUserStatus/list', params)
}

/**
 * 获取用户详情
 */
export const getCommunityUserStatusAPI = (params: CommunityUserStatusDetailParams) => {
  return http.get<components['schemas']['CommunityUserStatus']>(
    '/api/communityUserStatus/detail',
    params,
  )
}
